<template>
  <el-dialog title="测量类型" :visible.sync="show">
    <el-form :model="form_dialog">
      <el-form-item label="测量名称" :label-width="formLabelWidth">
        <el-input v-model="form_dialog.name" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="测量单位" :label-width="formLabelWidth">
        <el-input v-model="form_dialog.unit" autocomplete="off"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="$emit('update:dialogFormVisible', false)"
        >取 消</el-button
      >
      <el-button type="primary" @click="submit">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      // 宽度
      formLabelWidth: "120px",
    };
  },
  computed: {
    form_dialog() {
      return this.form;
    },
    show: {
      get() {
        return this.dialogFormVisible;
      },
      set(show) {
        this.$emit("update:dialogFormVisible", show);
      },
    },
  },
  props: ["dialogFormVisible", "form"],
  methods: {
    submit() {
      // 先更新父组件的form
      this.$emit("update:form", this.form_dialog);
      this.$emit("submit");
    },
  },
};
</script>

<style>
</style>